layui.use(['form','layer','laydate'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        laydate = layui.laydate,
        $ = layui.jquery;

    // 日期时间选择器
    laydate.render({
        elem: '.leaveDate'
        ,type: 'datetime'
        ,min: 0
        ,value: new Date()
    });

    // 监听提交
    form.on("submit(start)",function(data){

        //弹出loading
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});

        $.post("/qjlc/startProcessInstance",{
            leaveDate:$(".leaveDate").val(),
            days:$(".days").val(),
            content:$(".content").val(),
            remark:$(".remark").val(),
            status:$(".status").val(),
            key:$(".key").val()
        },function(res){
            top.layer.close(index);
            top.layer.msg(res.msg);
            setTimeout(function(){
                layer.closeAll("iframe");
                //刷新父页面
                parent.location.reload();
            },500);
        });

        return false;
    });

    // 取消按钮
    $(".cancle_btn").click(function(){
        var index=parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    })

});